//importing javascipt core modules
Components.utils.import("resource://downloadextender/common.js");
Components.utils.import("resource://downloadextender/downloadextender.js");

if ("undefined" == typeof(downloadextender)) {
  var downloadextender = {};
};

downloadextender.generalprefs = {  
  onload: function() {
    try {
	  let detectall = downloadextender.pref.detectall;
	  document.getElementById("downloadextenderdetectallcheck").setAttribute("checked", detectall);
	}
	catch (e) { downloadextender.consoleService("downloadextender.generalprefs.onload: "+e); }
  },
  ondetectallclick: function(checkbox) {
    try {
       	let detectallwarningheader = downloadextender.getlocalisedstring("prefwindow.properties", "downloadextender_detectall_warningheader");
		let detectallwarning = downloadextender.getlocalisedstring("prefwindow.properties", "downloadextender_detectall_warning");
		let detectallcheck = downloadextender.getlocalisedstring("prefwindow.properties", "downloadextender_detectall_check");
		let promptservice = downloadextender.promptservice();
	    let check = {value: false};	
 
        if 	(checkbox.checked == true) {
          let result = promptservice.confirmCheck(null, detectallwarningheader , detectallwarning, detectallcheck, check);
          if (check.value == true && result) {
		    document.getElementById("downloadextenderdetectallcheck").setAttribute("checked", true);		  
		  }
		  else {
		    document.getElementById("downloadextenderdetectallcheck").setAttribute("checked", false);		  
		  }
		}
		else {
          document.getElementById("downloadextenderdetectallcheck").setAttribute("checked", false);
		}
	 }
	 catch (e) { downloadextender.consoleService("ondetectallclick: "+e); }
  }
}